#ifndef __COBS_CODE_H_
#define __COBS_CODE_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "mytype.h"

	size_t cobs_encode(const uint8_t *src, size_t size, uint8_t *enc);

	size_t cobs_decode(const uint8_t *enc, size_t size, uint8_t *src);

	size_t cobs_encode_nz(const uint8_t *src, size_t size, uint8_t *enc);

	size_t cobs_decode_nz(const uint8_t *enc, size_t size, uint8_t *src);

	typedef struct
	{
		uint8_t *buff;
		uint16_t src_pos;
		uint16_t des_pos;
		uint16_t zero_pos;
		uint16_t buff_size;
		uint8_t code_dat;
		uint8_t dec_cnt;
	} cobs_rl_type;
	
	void cobs_encode_rl_begin(cobs_rl_type *obj, uint8_t *buff);
	void cobs_encode_rl(cobs_rl_type *obj, uint8_t dat);
	uint16_t cobs_encode_rl_end(cobs_rl_type *obj); 

	void cobs_decode_rl_begin(cobs_rl_type *obj,
							  uint8_t *buff, uint16_t bsize,
							  uint8_t dat);					
	int16_t cobs_decode_rl(cobs_rl_type *obj, uint8_t dat); 

#ifdef __cplusplus
}
#endif

#endif 
